<?php
@session_start();
include "config_db.php";
include "function.php";
if(empty($_SESSION['USERID'])||$_SESSION['IS_LOGIN'] !="OK"||empty($_SESSION['USERPW'])||$_SESSION['IS_LV']=='1'){
	MsgViewParent("잘못된 접근 방식입니다.","../index.php");
	session_destroy();
}else{
	$db_sql		= "SELECT * FROM `database` WHERE idx = ".$_SESSION['IS_DB_IDX'];
	$db_row		= MDBarray($db_sql);
	
	$local_host = 'localhost';
	$local_user = $db_row['id'];
	$local_pwd = Decode64($db_row['pw']);
	$local_db = $db_row['name'];
	$connect	=	@mysql_connect($local_host, $local_user, $local_pwd);  //DB connect
	@mysql_select_db($local_db,$connect) or die("db connect err");
	mysql_query("SET NAMES UTF8");
}

// mysql_query function
function DBquery($qry)
{
	global $connect;
	return mysql_query($qry,$connect);
}

// mysql_num_rows function
function DBnumrows($qry) {
	global $connect;
	$result = mysql_query($qry,$connect);
	return mysql_num_rows($result);
}

// mysql_fetch_array function
function DBarray($qry)
{
	global $connect;
	$result = @mysql_query($qry,$connect) or die("Qry Err. : $qry");
	return mysql_fetch_array($result);
}

// mysql_affected_rows function
function DBaffected($qry)
{
	global $connect;
	$result = @mysql_query($qry,$connect) or die("Qry Err. : $qry");
	return mysql_affected_rows();
}

function DBresult($qry)
{
	global $connect;
	$result = @mysql_query($qry,$connect) or die("Qry Err. : $qry");
	return mysql_result($result,0,0);
}

function DBobject($qry)
{
	global $connect;
	$result = @mysql_query($qry,$connect) or die("Qry Err. : $qry");
	return mysql_fetch_object($result);
}
?>